<template>
	<view style="touch-action: none;">
		<view class="home" style="position:fixed;" :style="{ top: top + 'px', bottom: bottom }" id="right-nav"
			@touchmove.stop.prevent="setTouchMove">
			
			<view @click="open" class="pictrueBox">
				<view class="pictrue">
					语言
				</view>
			</view>
		</view>
		<u-action-sheet :list="list" v-model="homeActive"></u-action-sheet>
	

	</view>
</template>
<script>
	import {
		mapState,
		mapActions
	} from 'vuex';
	export default {
		name: "Home",
		props: {},
		data: function() {
			return {
				homeActive: true,
				top: "",
				bottom: "",
				
				list: [{
						text: '中文'
					}, {
						text: '哈萨克语'
					},
					{
						text: '维吾尔语'
					},
				]
			};
		},

		methods: {
			...mapActions({
				switchLanguage: 'translate/switchLanguage',  // 映射 Vuex 中的 action
			}),
			setTouchMove(e) {
				var that = this;
				if (e.touches[0].clientY < 545 && e.touches[0].clientY > 66) {
					that.top = e.touches[0].clientY
					that.bottom = "auto";
				}
			},
			open: function() {
				let vm =this
				uni.showActionSheet({
					itemList: ['中文', '哈萨克语', '维吾尔语'],
					success: function (res) {
						console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
						vm.switchLanguage(res.tapIndex)
					},
					fail: function (res) {
						console.log(res.errMsg);
					}
				});

				// this.homeActive ? this.$store.commit("CLOSE_HOME") : this.$store.commit("OPEN_HOME");
			}
		},
		created() {
			this.bottom = "50px";
		}
	};
</script>

<style scoped>
	.pictrueBox {
		width: 130rpx;
		height: 120rpx;
	}

	/*返回主页按钮*/
	.home {
		position: fixed;
		color: white;
		text-align: center;
		z-index: 999;
		right: 15rpx;
		display: flex;
	}

	.home .homeCon {
		border-radius: 50rpx;
		opacity: 0;
		height: 0;
		color: #e93323;
		width: 0;
	}

	.home .homeCon.on {
		opacity: 1;
		animation: bounceInRight 0.5s cubic-bezier(0.215, 0.610, 0.355, 1.000);
		width: 300rpx;
		height: 86rpx;
		margin-bottom: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background: var(--view-theme);
	}

	.home .homeCon .iconfont {
		font-size: 48rpx;
		color: #fff;
		display: inline-block;
		margin: 0 auto;
	}

	.home .pictrue {
		width: 86rpx;
		height: 86rpx;
		border-radius: 50%;
		margin: 0 auto;
		/* background-color: var(--view-theme); */
		box-shadow: 0 5rpx 12rpx rgba(0, 0, 0, 0.5);
	}

	.home .pictrue .image {
		width: 100%;
		height: 100%;
	}

	.pictruea {
		width: 100%;
		height: 100%;
		display: block;
		object-fit: cover;
		vertical-align: middle;
	}
</style>